jQuery.fn.extend({
	quickAutoFill : function (options) {
		opts = jQuery.extend({

			requiredLorem : 'Lorem ipsum',
			requiredLongLorem : 'Lorem ipsum dolor sit amet, consectetuer sadipscing elitr.',
			emailLorem : 'test@domain.invalid',

			requiredClass : 'required',
			emailClass : 'email'		

		},options);
	
		return this.find('input,textarea').each(function() {
			$this = $(this);
			if ($this.hasClass(opts.requiredClass)) {
				if ($this.is('[type=text]'))
					this.value = opts.requiredLorem;
				else if ($this.is('textarea'))
					$this.append(opts.requiredLongLorem);
				else if ($this.is('[type=checkbox]'))
					this.checked = 'checked';				
			}

			if ($this.hasClass(opts.emailClass)) {
				this.value = opts.emailLorem;
			}
		});
	},

	addLoremIpsum : function (ipsum) {
		if(this.is(':input')) this.data('ipsum',ipsum);
		return this;
	},

	autoFill : function (options) {
		return this.find(':input').each(
			function() {
				$this = jQuery(this);
				ipsum = $this.data('ipsum');
				opts = $this.data('opts');

				if (ipsum) {
					if($this.is('select')) {
						switch (typeof ipsum) {
							case 'number':
								$this.val(ipsum);
							case 'object':
								jQuery.each(ipsum, function(key, val){
									$this.find('option[value=' + val +']').attr('selected','selected');
								});
						}
					}
					else if($this.is('textarea'))
						$this.append(ipsum);	
					else if ($this.is('input[type=text], input[type=hidden]'))
						this.value = ipsum;
					else if($this.is('input[type=checkbox],input[type=radio]]'))
						$this.attr('checked', 'checked');
				}
			}
		);
	}
});
